﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NotAClue.ComponentModel.DataAnnotations
{
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
    public class RowHighlightingByDateAttribute : Attribute
    {
        /// <summary>
        /// Gets or sets the column to compare.
        /// </summary>
        /// <value>The column to compare.</value>
        public String CompareToColumn { get; set; }

        /// <summary>
        /// Gets or sets the incomplete CSS.
        /// </summary>
        /// <value>The incomplete CSS class.</value>
        public String BeforeDateCss { get; set; }

        /// <summary>
        /// Gets or sets the before date text.
        /// </summary>
        /// <value>The before date text.</value>
        public String BeforeDateText { get; set; }

        /// <summary>
        /// Gets or sets the dead line approaching CSS.
        /// </summary>
        /// <value>The dead line approaching CSS class.</value>
        public String ApproachingDateCss { get; set; }

        /// <summary>
        /// Gets or sets the approaching date text.
        /// </summary>
        /// <value>The approaching date text.</value>
        public String ApproachingDateText { get; set; }

        /// <summary>
        /// Gets or sets the dead line exceeded CSS.
        /// </summary>
        /// <value>The dead line exceeded CSS class.</value>
        public String PassedDateCss { get; set; }

        /// <summary>
        /// Gets or sets the after date CSS.
        /// </summary>
        /// <value>The after date CSS.</value>
        public String AfterDateCss { get; set; }

        /// <summary>
        /// Gets or sets the passed date text.
        /// </summary>
        /// <value>The passed date text.</value>
        public String PassedDateText { get; set; }

        /// <summary>
        /// Gets or sets the complete.
        /// </summary>
        /// <value>The complete.</value>
        public String CompleteCss { get; set; }

        /// <summary>
        /// Gets or sets the days.
        /// </summary>
        /// <value>The days.</value>
        public int Days { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="RowHighlightingByDateAttribute"/> class.
        /// </summary>
        /// <param name="compareToColumn">The compare to column.</param>
        /// <param name="days">The days.</param>
        /// <param name="beforeDateCss">The incomplete CSS.</param>
        /// <param name="approachingDateCss">The dead line approaching CSS.</param>
        /// <param name="passedDateCss">The dead line exceeded CSS.</param>
        public RowHighlightingByDateAttribute(
            String compareToColumn,
            int days,
            String beforeDateCss,
            String approachingDateCss,
            String passedDateCss,
            String completeCss)
        {
            CompareToColumn = compareToColumn;
            Days = days;
            BeforeDateCss = beforeDateCss;
            ApproachingDateCss = approachingDateCss;
            PassedDateCss = passedDateCss;
            CompleteCss = completeCss;

            if (BeforeDateText == null)
                BeforeDateText = "{0}days before deadline.";
            if (ApproachingDateText == null)
                ApproachingDateText = "Deadline in {0}day(s).";
            if (PassedDateText == null)
                PassedDateText = "Passed deadline by {0}day(s).";
            if (AfterDateCss != null)
                AfterDateCss = PassedDateCss;
        }
    }
}
